package com.byedu.domain.course.vo;

import com.byedu.domain.course.AnswerDO;

import java.io.Serializable;

public class AnswerVO implements Serializable{

	private static final long serialVersionUID = -5999268134805615509L;

    /*答案编号*/
    private Integer id;
    /*选项*/
    private String subOption;
    /*选项内容*/
    private String content;
    /*是否为正确答案*/
    private boolean correct;
    /*考题编号*/
    private int questionId;
    /*用户是否已做过该题目*/
    private boolean checked;

    public AnswerVO () {}


    public AnswerVO (AnswerDO answerDO) {
        this.id = answerDO.getId();
        this.subOption = answerDO.getSubOption();
        this.content = answerDO.getContent();
        this.correct = answerDO.isCorrect();
        this.questionId = answerDO.getQuestionId();
    }
//    public AnswerVO (AnswerDO answerDO, UserQuestionDO userQuestionDO) {
//         this.id = answerDO.getId();
//         this.subOption = answerDO.getSubOption();
//         this.content = answerDO.getContent();
//         this.correct = answerDO.isCorrect();
//         this.questionId = answerDO.getQuestionId();
//         if (answerDO != null && userQuestionDO != null && userQuestionDO.getQuestionId() == answerDO.getQuestionId()) {
//             if (userQuestionDO.getSubOption().equals(answerDO.getSubOption())) {
//                 this.checked = true;
//             }
//         }
//    }

//    public AnswerVO (AnswerDO answerDO, boolean checked) {
//        this.id = answerDO.getId();
//        this.subOption = answerDO.getSubOption();
//        this.content = answerDO.getContent();
//        this.correct = answerDO.isCorrect();
//        this.questionId = answerDO.getQuestionId();
//        this.checked = checked;
//    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getSubOption() {
        return subOption;
    }

    public void setSubOption(String subOption) {
        this.subOption = subOption;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public boolean isCorrect() {
        return correct;
    }

    public void setCorrect(boolean correct) {
        this.correct = correct;
    }

    public int getQuestionId() {
        return questionId;
    }

    public void setQuestionId(int questionId) {
        this.questionId = questionId;
    }

    public boolean isChecked() {
        return checked;
    }

    public void setChecked(boolean checked) {
        this.checked = checked;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        AnswerVO answerVO = (AnswerVO) o;

        if (id != null ? !id.equals(answerVO.id) : answerVO.id != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }

    @Override
    public String toString() {
        return "AnswerVO{" +
                "id=" + id +
                ", subOption=" + subOption +
                ", content='" + content + '\'' +
                ", correct=" + correct +
                ", questionId=" + questionId +
                ", checked=" + checked +
                '}';
    }
}
